import 'package:vista/shared/models/base_frame.dart';

/// 评论拍摄
/// 存储评论信息，如摄影中的拍摄般记录评论内容
class CommentShot extends BaseFrame {
  final String id; // 评论ID
  final String postId; // 动态ID
  final String userId; // 用户ID
  final String content; // 评论内容
  final DateTime timestamp; // 评论时间

  const CommentShot({
    required this.id,
    required this.postId,
    required this.userId,
    required this.content,
    required this.timestamp,
  });

  /// 从JSON创建评论拍摄
  factory CommentShot.fromJson(Map<String, dynamic> json) {
    return CommentShot(
      id: json['id'] as String,
      postId: json['postId'] as String,
      userId: json['userId'] as String,
      content: json['content'] as String,
      timestamp: DateTime.parse(json['timestamp'] as String),
    );
  }

  @override
  List<Object?> get props => [id, postId, userId, content, timestamp];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'postId': postId,
      'userId': userId,
      'content': content,
      'timestamp': timestamp.toIso8601String(),
    };
  }
}
